package com.hongyuan.coach.ui.home.view_mode;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;
import com.hongyuan.mvvmhabitx.binding.command.BindingAction;
import com.hongyuan.mvvmhabitx.binding.command.BindingCommand;
import com.hongyuan.coach.base.ItemViewModel;
import com.hongyuan.coach.ui.home.activity.CancelAppointmentActivity;
import com.hongyuan.coach.ui.home.beans.HomeContentBean;

public class HomeItemViewModel extends ItemViewModel<HomeViewMode> {

    public ObservableField<HomeContentBean.ListBean> entity = new ObservableField<>();

    public HomeItemViewModel(@NonNull HomeViewMode viewModel, HomeContentBean.ListBean bean) {
        super(viewModel);

        entity.set(bean);
    }

    //拨打电话
    public BindingCommand callTel = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            viewModel.getUC().getCallTel().setValue(entity.get().getM_mobile());
        }
    });


    //查看
    public BindingCommand goLook = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            if(entity.get().getState() == 5){
                Bundle bundle = new Bundle();
                bundle.putSerializable("stu",entity.get());
                viewModel.startActivity(CancelAppointmentActivity.class,bundle);
            }
        }
    });
}
